﻿using UnityEngine;
using System.Collections;
using System;

public class MainRole : Role
{

    public override void Init(CreateSceneRole serverData, RoleDatabase tableData)
    {
        base.Init(serverData, tableData);

        Debug.Log("MainRole 初始化");
        //绑定控制事件
        FightUIMgr.instance.BindingJoystick(OnJoystickMove,OnJoystickMoveEnd);

        FightUIMgr.instance.BindingTouchScene(onTouchSth);
    }


    private void OnJoystickMoveEnd()
    {
        StopMove();
        Debug.Log("移动结束");
    }

    private void OnJoystickMove(Vector2 dir)
    {
        Debug.Log("移动方向：" + dir);

        var speed = 1;

        var target = this.transform.position + new Vector3(dir.x, 0, dir.y) * speed;
        
        PathTo(target);

    }

    private void onTouchSth(RaycastHit hitRet)
    {
        Debug.Log("点击屏幕" + hitRet.point);

        PathTo(hitRet.point);
    }


}
